from django import forms

from fun.models import *


class RecordForms(forms.Form):
    title = forms.CharField(
        label='标题',
        min_length=4,
        max_length=30,
        error_messages={
            'min_length': '长度小于4',
            'max_length': '长度大于30'
        }
    )
    description = forms.CharField(
        label='描述信息',
        min_length=4,
        max_length=100,
        error_messages={
            'min_length': '长度小于4',
            'max_length': '长度大于100'
        }
    )
    content = forms.CharField(
        label='内容',
        widget=forms.Textarea()
    )
    picture = forms.FileField(
        label='图片'
    )
    classify = forms.ModelChoiceField(
        label='选择分类',
        queryset=Classify.objects.all(),
        empty_label=None
    )
    label = forms.ModelMultipleChoiceField(
        label='选择标签',
        queryset=Label.objects.all()
    )


class UserForms(forms.Form):
    nickname = forms.CharField(
        label='昵称',
        min_length=2,
        max_length=30,
        error_messages={
            'min_length': '长度小于2',
            'max_length': '长度大于30'
        }
    )
    age = forms.IntegerField(
        label='年龄',
    )
    sex = forms.ChoiceField(
        label='性别',
        choices=((1, '男'), (2, '女'), (3, '保密')),
        widget=forms.RadioSelect(),
        initial=3
    )
    birthday = forms.DateField(
        required=False,
        label='生日(年-月-日)',
        # min_length=4,
        # max_length=100,
    )
    QQ = forms.IntegerField(
        label='QQ号',
    )
